<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">

	<title>Editor example - DOM sourced table</title>
	<link rel="stylesheet" type="text/css" href="../../../../media/css/jquery.dataTables.css">
	<link rel="stylesheet" type="text/css" href="../../../TableTools/css/dataTables.tableTools.css">
	<link rel="stylesheet" type="text/css" href="../../css/dataTables.editor.css">
	<link rel="stylesheet" type="text/css" href="../../../../examples/resources/syntax/shCore.css">
	<link rel="stylesheet" type="text/css" href="../../../../examples/resources/demo.css">
	<style type="text/css" class="init">

	</style>
	<script type="text/javascript" language="javascript" src="../../../../media/js/jquery.js"></script>
	<script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js"></script>
	<script type="text/javascript" language="javascript" src="../../../TableTools/js/dataTables.tableTools.js"></script>
	<script type="text/javascript" language="javascript" src="../../js/dataTables.editor.js"></script>
	<script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
	<script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
	<script type="text/javascript" language="javascript" src="../resources/editor-demo.js"></script>
	<script type="text/javascript" language="javascript" class="init">



var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
	editor = new $.fn.dataTable.Editor( {
		ajax: '../php/staff-array.php',
		table: '#example',
		fields: [ {
				label: 'First name:',
				name: 0
			}, {
				label: 'Last name:',
				name: 1
			}, {
				label: 'Position:',
				name: 2
			}, {
				label: 'Office:',
				name: 3
			}, {
				label: 'Salary:',
				name: 4,
				data: function (row, type, val) {
					// Strip the formatting from the salary number
					if ( type === 'set' ) {
						row[4] = val;
					}
					return row[4].replace(/[^0-9]/g, '');
				}
			}
		]
	} );

	$('#example').DataTable( {
		dom: 'Tfrtip',
		tableTools: {
			sRowSelect: 'os',
			aButtons: [
				{ sExtends: 'editor_create', editor: editor },
				{ sExtends: 'editor_edit',   editor: editor },
				{ sExtends: 'editor_remove', editor: editor }
			]
		}
	} );
} );



	</script>
</head>

<body class="dt-example">
	<div class="container">
		<section>
			<h1>Editor example <span>DOM sourced table</span></h1>

			<div class="info">
				<p>Although many of the Editor examples show the data for the table being loaded by Ajax (<a href=
				"//datatables.net/reference/option/ajax"><code class="option" title=
				"DataTables initialisation option">ajax<span>DT</span></code></a>) this is by no means mandatory.
				Editor will work with any data source that DataTables can use, with the only additional requirement
				that each row has a unique ID (allowing the server to identify which rows to update, delete, etc).</p>

				<p>This example shows Editor being applied to a plain HTML table (generated by PHP from the database,
				although it could come from absolutely anywhere). Ajax requests are still used for create, edit and
				remove actions, but not for loading the initial data.</p>

				<p>Note that the Editor fields are initialised with the <a href=
				"//editor.datatables.net/reference/option/fields.name"><code class="option" title=
				"Editor initialisation option">fields.name<span>E</span></code></a> option specified, and the given
				value relates to the column index in the DataTable. This allows editor to map between the array indexes
				used by DataTables for this table, and the names used for the field in the form.</p>
			</div>

			<table id="example" class="display" cellspacing="0" width="100%">
				<thead>
					<tr>
						<th>First name</th>
						<th>Last name</th>
						<th>Position</th>
						<th>Office</th>
						<th>Salary</th>
					</tr>
				</thead>

				<tbody>
					<tr id="row_1">
						<td>Tiger</td>
						<td>Nixon</td>
						<td>System Architect</td>
						<td>Edinburgh</td>
						<td>$320,800</td>
					</tr>
					<tr id="row_2">
						<td>Garrett</td>
						<td>Winters</td>
						<td>Accountant</td>
						<td>Tokyo</td>
						<td>$170,750</td>
					</tr>
					<tr id="row_3">
						<td>Ashton</td>
						<td>Cox</td>
						<td>Junior Technical Author</td>
						<td>San Francisco</td>
						<td>$86,000</td>
					</tr>
					<tr id="row_4">
						<td>Cedric</td>
						<td>Kelly</td>
						<td>Senior Javascript Developer</td>
						<td>Edinburgh</td>
						<td>$433,060</td>
					</tr>
					<tr id="row_5">
						<td>Airi</td>
						<td>Satou</td>
						<td>Accountant</td>
						<td>Tokyo</td>
						<td>$162,700</td>
					</tr>
					<tr id="row_6">
						<td>Brielle</td>
						<td>Williamson</td>
						<td>Integration Specialist</td>
						<td>New York</td>
						<td>$372,000</td>
					</tr>
					<tr id="row_7">
						<td>Herrod</td>
						<td>Chandler</td>
						<td>Sales Assistant</td>
						<td>San Francisco</td>
						<td>$137,500</td>
					</tr>
					<tr id="row_8">
						<td>Rhona</td>
						<td>Davidson</td>
						<td>Integration Specialist</td>
						<td>Tokyo</td>
						<td>$327,900</td>
					</tr>
					<tr id="row_9">
						<td>Colleen</td>
						<td>Hurst</td>
						<td>Javascript Developer</td>
						<td>San Francisco</td>
						<td>$205,500</td>
					</tr>
					<tr id="row_10">
						<td>Sonya</td>
						<td>Frost</td>
						<td>Software Engineer</td>
						<td>Edinburgh</td>
						<td>$103,600</td>
					</tr>
					<tr id="row_11">
						<td>Jena</td>
						<td>Gaines</td>
						<td>Office Manager</td>
						<td>London</td>
						<td>$90,560</td>
					</tr>
					<tr id="row_12">
						<td>Quinn</td>
						<td>Flynn</td>
						<td>Support Lead</td>
						<td>Edinburgh</td>
						<td>$342,000</td>
					</tr>
					<tr id="row_13">
						<td>Charde</td>
						<td>Marshall</td>
						<td>Regional Director</td>
						<td>San Francisco</td>
						<td>$470,600</td>
					</tr>
					<tr id="row_14">
						<td>Haley</td>
						<td>Kennedy</td>
						<td>Senior Marketing Designer</td>
						<td>London</td>
						<td>$313,500</td>
					</tr>
					<tr id="row_15">
						<td>Tatyana</td>
						<td>Fitzpatrick</td>
						<td>Regional Director</td>
						<td>London</td>
						<td>$385,750</td>
					</tr>
					<tr id="row_16">
						<td>Michael</td>
						<td>Silva</td>
						<td>Marketing Designer</td>
						<td>London</td>
						<td>$198,500</td>
					</tr>
					<tr id="row_17">
						<td>Paul</td>
						<td>Byrd</td>
						<td>Chief Financial Officer (CFO)</td>
						<td>New York</td>
						<td>$725,000</td>
					</tr>
					<tr id="row_18">
						<td>Gloria</td>
						<td>Little</td>
						<td>Systems Administrator</td>
						<td>New York</td>
						<td>$237,500</td>
					</tr>
					<tr id="row_19">
						<td>Bradley</td>
						<td>Greer</td>
						<td>Software Engineer</td>
						<td>London</td>
						<td>$132,000</td>
					</tr>
					<tr id="row_20">
						<td>Dai</td>
						<td>Rios</td>
						<td>Personnel Lead</td>
						<td>Edinburgh</td>
						<td>$217,500</td>
					</tr>
					<tr id="row_21">
						<td>Jenette</td>
						<td>Caldwell</td>
						<td>Development Lead</td>
						<td>New York</td>
						<td>$345,000</td>
					</tr>
					<tr id="row_22">
						<td>Yuri</td>
						<td>Berry</td>
						<td>Chief Marketing Officer (CMO)</td>
						<td>New York</td>
						<td>$675,000</td>
					</tr>
					<tr id="row_23">
						<td>Caesar</td>
						<td>Vance</td>
						<td>Pre-Sales Support</td>
						<td>New York</td>
						<td>$106,450</td>
					</tr>
					<tr id="row_24">
						<td>Doris</td>
						<td>Wilder</td>
						<td>Sales Assistant</td>
						<td>Sidney</td>
						<td>$85,600</td>
					</tr>
					<tr id="row_25">
						<td>Angelica</td>
						<td>Ramos</td>
						<td>Chief Executive Officer (CEO)</td>
						<td>London</td>
						<td>$1,200,000</td>
					</tr>
					<tr id="row_26">
						<td>Gavin</td>
						<td>Joyce</td>
						<td>Developer</td>
						<td>Edinburgh</td>
						<td>$92,575</td>
					</tr>
					<tr id="row_27">
						<td>Jennifer</td>
						<td>Chang</td>
						<td>Regional Director</td>
						<td>Singapore</td>
						<td>$357,650</td>
					</tr>
					<tr id="row_28">
						<td>Brenden</td>
						<td>Wagner</td>
						<td>Software Engineer</td>
						<td>San Francisco</td>
						<td>$206,850</td>
					</tr>
					<tr id="row_29">
						<td>Fiona</td>
						<td>Green</td>
						<td>Chief Operating Officer (COO)</td>
						<td>San Francisco</td>
						<td>$850,000</td>
					</tr>
					<tr id="row_30">
						<td>Shou</td>
						<td>Itou</td>
						<td>Regional Marketing</td>
						<td>Tokyo</td>
						<td>$163,000</td>
					</tr>
					<tr id="row_31">
						<td>Michelle</td>
						<td>House</td>
						<td>Integration Specialist</td>
						<td>Sidney</td>
						<td>$95,400</td>
					</tr>
					<tr id="row_32">
						<td>Suki</td>
						<td>Burks</td>
						<td>Developer</td>
						<td>London</td>
						<td>$114,500</td>
					</tr>
					<tr id="row_33">
						<td>Prescott</td>
						<td>Bartlett</td>
						<td>Technical Author</td>
						<td>London</td>
						<td>$145,000</td>
					</tr>
					<tr id="row_34">
						<td>Gavin</td>
						<td>Cortez</td>
						<td>Team Leader</td>
						<td>San Francisco</td>
						<td>$235,500</td>
					</tr>
					<tr id="row_35">
						<td>Martena</td>
						<td>Mccray</td>
						<td>Post-Sales support</td>
						<td>Edinburgh</td>
						<td>$324,050</td>
					</tr>
					<tr id="row_36">
						<td>Unity</td>
						<td>Butler</td>
						<td>Marketing Designer</td>
						<td>San Francisco</td>
						<td>$85,675</td>
					</tr>
					<tr id="row_37">
						<td>Howard</td>
						<td>Hatfield</td>
						<td>Office Manager</td>
						<td>San Francisco</td>
						<td>$164,500</td>
					</tr>
					<tr id="row_38">
						<td>Hope</td>
						<td>Fuentes</td>
						<td>Secretary</td>
						<td>San Francisco</td>
						<td>$109,850</td>
					</tr>
					<tr id="row_39">
						<td>Vivian</td>
						<td>Harrell</td>
						<td>Financial Controller</td>
						<td>San Francisco</td>
						<td>$452,500</td>
					</tr>
					<tr id="row_40">
						<td>Timothy</td>
						<td>Mooney</td>
						<td>Office Manager</td>
						<td>London</td>
						<td>$136,200</td>
					</tr>
					<tr id="row_41">
						<td>Jackson</td>
						<td>Bradshaw</td>
						<td>Director</td>
						<td>New York</td>
						<td>$645,750</td>
					</tr>
					<tr id="row_42">
						<td>Olivia</td>
						<td>Liang</td>
						<td>Support Engineer</td>
						<td>Singapore</td>
						<td>$234,500</td>
					</tr>
					<tr id="row_43">
						<td>Bruno</td>
						<td>Nash</td>
						<td>Software Engineer</td>
						<td>London</td>
						<td>$163,500</td>
					</tr>
					<tr id="row_44">
						<td>Sakura</td>
						<td>Yamamoto</td>
						<td>Support Engineer</td>
						<td>Tokyo</td>
						<td>$139,575</td>
					</tr>
					<tr id="row_45">
						<td>Thor</td>
						<td>Walton</td>
						<td>Developer</td>
						<td>New York</td>
						<td>$98,540</td>
					</tr>
					<tr id="row_46">
						<td>Finn</td>
						<td>Camacho</td>
						<td>Support Engineer</td>
						<td>San Francisco</td>
						<td>$87,500</td>
					</tr>
					<tr id="row_47">
						<td>Serge</td>
						<td>Baldwin</td>
						<td>Data Coordinator</td>
						<td>Singapore</td>
						<td>$138,575</td>
					</tr>
					<tr id="row_48">
						<td>Zenaida</td>
						<td>Frank</td>
						<td>Software Engineer</td>
						<td>New York</td>
						<td>$125,250</td>
					</tr>
					<tr id="row_49">
						<td>Zorita</td>
						<td>Serrano</td>
						<td>Software Engineer</td>
						<td>San Francisco</td>
						<td>$115,000</td>
					</tr>
					<tr id="row_50">
						<td>Jennifer</td>
						<td>Acosta</td>
						<td>Junior Javascript Developer</td>
						<td>Edinburgh</td>
						<td>$75,650</td>
					</tr>
					<tr id="row_51">
						<td>Cara</td>
						<td>Stevens</td>
						<td>Sales Assistant</td>
						<td>New York</td>
						<td>$145,600</td>
					</tr>
					<tr id="row_52">
						<td>Hermione</td>
						<td>Butler</td>
						<td>Regional Director</td>
						<td>London</td>
						<td>$356,250</td>
					</tr>
					<tr id="row_53">
						<td>Lael</td>
						<td>Greer</td>
						<td>Systems Administrator</td>
						<td>London</td>
						<td>$103,500</td>
					</tr>
					<tr id="row_54">
						<td>Jonas</td>
						<td>Alexander</td>
						<td>Developer</td>
						<td>San Francisco</td>
						<td>$86,500</td>
					</tr>
					<tr id="row_55">
						<td>Shad</td>
						<td>Decker</td>
						<td>Regional Director</td>
						<td>Edinburgh</td>
						<td>$183,000</td>
					</tr>
					<tr id="row_56">
						<td>Michael</td>
						<td>Bruce</td>
						<td>Javascript Developer</td>
						<td>Singapore</td>
						<td>$183,000</td>
					</tr>
					<tr id="row_57">
						<td>Donna</td>
						<td>Snider</td>
						<td>Customer Support</td>
						<td>New York</td>
						<td>$112,000</td>
					</tr>
				</tbody>
			</table>

			<ul class="tabs">
				<li class="active">Javascript</li>
				<li>HTML</li>
				<li>CSS</li>
				<li>Ajax</li>
				<li>Server-side script</li>
			</ul>

			<div class="tabs">
				<div class="js">
					<p>The Javascript shown below is used to initialise the table shown in this
					example:</p><code class="multiline brush: js;">var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
	editor = new $.fn.dataTable.Editor( {
		ajax: '../php/staff-array.php',
		table: '#example',
		fields: [ {
				label: 'First name:',
				name: 0
			}, {
				label: 'Last name:',
				name: 1
			}, {
				label: 'Position:',
				name: 2
			}, {
				label: 'Office:',
				name: 3
			}, {
				label: 'Salary:',
				name: 4,
				data: function (row, type, val) {
					// Strip the formatting from the salary number
					if ( type === 'set' ) {
						row[4] = val;
					}
					return row[4].replace(/[^0-9]/g, '');
				}
			}
		]
	} );

	$('#example').DataTable( {
		dom: 'Tfrtip',
		tableTools: {
			sRowSelect: 'os',
			aButtons: [
				{ sExtends: 'editor_create', editor: editor },
				{ sExtends: 'editor_edit',   editor: editor },
				{ sExtends: 'editor_remove', editor: editor }
			]
		}
	} );
} );</code>

					<p>In addition to the above code, the following Javascript library files are loaded for use in this
					example:</p>

					<ul>
						<li><a href="../../../../media/js/jquery.js">../../../../media/js/jquery.js</a></li>
						<li><a href=
						"../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
						<li><a href=
						"../../../TableTools/js/dataTables.tableTools.js">../../../TableTools/js/dataTables.tableTools.js</a></li>
						<li><a href="../../js/dataTables.editor.js">../../js/dataTables.editor.js</a></li>
					</ul>
				</div>

				<div class="table">
					<p>The HTML shown below is the raw HTML table element, before it has been enhanced by
					DataTables:</p>
				</div>

				<div class="css">
					<div>
						<p>This example uses a little bit of additional CSS beyond what is loaded from the library
						files (below), in order to correctly display the table. The additional CSS used is shown
						below:</p><code class="multiline brush: js;"></code>
					</div>

					<p>The following CSS library files are loaded for use in this example to provide the styling of the
					table:</p>

					<ul>
						<li><a href=
						"../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
						<li><a href=
						"../../../TableTools/css/dataTables.tableTools.css">../../../TableTools/css/dataTables.tableTools.css</a></li>
						<li><a href="../../css/dataTables.editor.css">../../css/dataTables.editor.css</a></li>
					</ul>
				</div>

				<div class="ajax">
					<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
					will update automatically as any additional data is loaded.</p>
				</div>

				<div class="php">
					<p>The script used to perform the server-side processing for this table is shown below. Please note
					that this is just an example script using PHP. Server-side processing scripts can be written in any
					language, using <a href="//datatables.net/manual/server-side">the protocol described in the
					DataTables documentation</a>.</p>
				</div>
			</div>
		</section>
	</div>

	<section>
		<div class="footer">
			<div class="gradient"></div>

			<div class="liner">
				<h2>Other examples</h2>

				<div class="toc">
					<div class="toc-group">
						<h3><a href="../simple/index.html">Simple initialisation</a></h3>
						<ul class="toc">
							<li><a href="../simple/simple.html">Basic initialisation</a></li>
							<li><a href="../simple/fieldDefaults.html">Setting defaults</a></li>
							<li><a href="../simple/fieldTypes.html">Field types</a></li>
							<li><a href="../simple/dates.html">Dates (with jQuery UI datepicker)</a></li>
							<li><a href="../simple/i18n.html">Internationalisation</a></li>
							<li><a href="../simple/inTableControls.html">In table form controls</a></li>
							<li><a href="../simple/responsive.html">Responsive table extension</a></li>
							<li><a href="../simple/server-side-processing.html">Server-side processing</a></li>
							<li><a href="../simple/join.html">Join tables - working with multiple SQL tables</a></li>
						</ul>
					</div>

					<div class="toc-group">
						<h3><a href="./index.html">Advanced initialisation</a></h3>
						<ul class="toc active">
							<li><a href="./formOnlyData.html">Data shown only in the form</a></li>
							<li><a href="./tableOnlyData.html">Data shown in table only</a></li>
							<li><a href="./deepObjects.html">Complex (nested) JSON data source</a></li>
							<li><a href="./REST.html">REST interface</a></li>
							<li><a href="./localstorage.html">Ajax override - using localStorage for the data
							source</a></li>
							<li><a href="./jsonId.html">Row ID source specification</a></li>
							<li class="active"><a href="./htmlTable.html">DOM sourced table</a></li>
							<li><a href="./exportButtons.html">Export buttons</a></li>
							<li><a href="./joinSelf.html">Join tables - self referencing join</a></li>
							<li><a href="./joinLinkTable.html">Join tables - link table</a></li>
							<li><a href="./joinArray.html">Join tables - one-to-many join</a></li>
						</ul>
					</div>

					<div class="toc-group">
						<h3><a href="../bubble-editing/index.html">Bubble editing</a></h3>
						<ul class="toc">
							<li><a href="../bubble-editing/simple.html">Simple bubble editing</a></li>
							<li><a href="../bubble-editing/grouped.html">Multiple fields in a bubble</a></li>
							<li><a href="../bubble-editing/options.html">Form control and display options</a></li>
							<li><a href="../bubble-editing/defaultOptions.html">Default control and display
							options</a></li>
							<li><a href="../bubble-editing/inTableControls.html">Bubble editing with in table row
							controls</a></li>
						</ul>
					</div>

					<div class="toc-group">
						<h3><a href="../inline-editing/index.html">Inline editing</a></h3>
						<ul class="toc">
							<li><a href="../inline-editing/simple.html">Simple inline editing</a></li>
							<li><a href="../inline-editing/tabControl.html">Tab between columns</a></li>
							<li><a href="../inline-editing/options.html">Editing options - submit on blur</a></li>
							<li><a href="../inline-editing/submitButton.html">Inline editing with a submit
							button</a></li>
							<li><a href="../inline-editing/editIcon.html">Edit icon</a></li>
						</ul>
					</div>

					<div class="toc-group">
						<h3><a href="../api/index.html">API</a></h3>
						<ul class="toc">
							<li><a href="../api/confirmClose.html">Events - unsaved changes close confirmation</a></li>
							<li><a href="../api/clientValidation.html">Client-side validation</a></li>
							<li><a href="../api/triggerButton.html">Customised control buttons</a></li>
							<li><a href="../api/backNext.html">Previous / next editing buttons</a></li>
							<li><a href="../api/duplicateButton.html">Duplicate button</a></li>
						</ul>
					</div>

					<div class="toc-group">
						<h3><a href="../standalone/index.html">Standalone</a></h3>
						<ul class="toc">
							<li><a href="../standalone/simple.html">Simple standalone editing</a></li>
							<li><a href="../standalone/bubble.html">Bubble editing</a></li>
							<li><a href="../standalone/inline.html">Inline editing</a></li>
						</ul>
					</div>

					<div class="toc-group">
						<h3><a href="../styling/index.html">Styling</a></h3>
						<ul class="toc">
							<li><a href="../styling/envelope.html">Envelope display controller</a></li>
							<li><a href="../styling/envelopeInTable.html">Envelope display with in table
							controls</a></li>
							<li><a href="../styling/stackedInputs.html">Styled for stacked inputs</a></li>
							<li><a href="../styling/bootstrap.html">Bootstrap</a></li>
							<li><a href="../styling/jqueryui.html">jQuery UI</a></li>
						</ul>
					</div>

					<div class="toc-group">
						<h3><a href="../plug-ins/index.html">Plug-ins</a></h3>
						<ul class="toc">
							<li><a href="../plug-ins/fieldPlugin.html">Custom field type plug-ins</a></li>
							<li><a href="../plug-ins/displayController.html">Custom display controller</a></li>
						</ul>
					</div>
				</div>

				<div class="epilogue">
					<p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
					information about its API properties and methods.<br>
					Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
					<a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
					DataTables.</p>

					<p class="copyright">DataTables designed and created by <a href=
					"http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
					DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
				</div>
			</div>
		</div>
	</section>
</body>
</html>